Use several pieces of code to clarify the concepts and associations of $ injector, $ rootScope, and $ scope in angularJS.
$ Injector, $ rootScope, and $ scope are important in the angularJS framework. clarifying the relationship between them is very
$injector, $rootScope, and $scope are important things in the AngularJS framework, and it is useful for us to follow up on the AngularJS framework of learning and understanding.1.$injector is actually an IOC container that contains a lot of services
$rootScope$rootScope is the top-level scope, which corresponds to the DOM element that contains the ng-app directive attribute. app.run (function ($rootScope) {$rootScope. Name = "Ari Lerner";$rootScope.test = new Date();});The App.run function is
1,js Code
The code is as follows
Copy Code
Phonecatapp.controller (' Testctrl ', [' $scope ', ' $rootScope ',function ($scope, $rootScope) {$rootScope. Name = ' This is test ';}]);Phonecatapp.controller (' Test111ctrl ',
The beast's Ng API learns--$rootScope. ScopeHere are some scope operations, such as create/logout/various listening and communication between scopes and so on.$rootScope. ScopeYou can use $injector to retrieve a root scope by using the $rootscope
A word summary:
$rootScope is active for the global scope
$scope only takes effect for the current controller scope
Use the following example to prove the above statement:
Define a module named MyApp
var myApp = angular.module (' myApp ',
I. The difference between $scope and $rootscopeA sentence summary:$rootScope the scope for the global takes effect$scope only valid for the current controller scopeSecond, the Angularjs module of the Run methodThe Run method initializes the global
After upgrading iOS9, the app developed by Ionic will report [$rootScope: Infdig] $digest () iterations reached. aborting! error, plus a patch to fix it.Introduce JS in index.htmlApp.js added dependency ' Ngios9uiwebviewpatch 'Angular.module ('
AngularJS provides good $cookie and $cookieStore APIs to handle cookies.Both services are able to play HTML5 cookies well, and when the HTML5 API is available the browser chooses to use the API provided by HTML5 and, if not available, chooses
AngularJS advanced (34) Angular Data is not updated in a timely mannerAngular Data Update Is Not timely
When the control badge is changed correctly, it is found that the front-end code organization level has a serious problem. RootScope is used when
Introduced
When it comes to the development of computer software, I want to use all the latest technology. For example, the front-end uses the latest JavaScript technology, and the server side uses the latest REST-based Web API service. In addition,
This article mainly introduces in detail how to use AngularJS built-in commands. It is very detailed and summarizes some commonly used commands and operations. If you have any need, refer to the following commands, I understand AngularJS as a way to
This article mainly introduces in detail how to use AngularJS built-in commands. it is very detailed and summarizes some commonly used commands and operations. if you have any need, refer to the following commands, I understand AngularJS as a way to
$httpAngularJS $http Service allows us to communicate with the background by sending HTTP requests. In some cases, we want to be able to capture all requests and operate before sending them to the server. In other cases, we want to capture the
This article illustrates the method of Angularjs to realize user login status. Share to everyone for your reference, specific as follows:
When using Angularjs's single page application, because it is local routing in the control page jump, but
Test your application1. Test the route we need to detect if the route is working, whether it is found, or 404. We want to confirm that the routed event is triggered and that the expected template is actually loaded. Since routing changes the address
Catalogue
First put the project address: The author is just getting started, each step is very difficult, basic knowledge of each point is relying on Baidu, just began to feel very hard, and slowly found the struggle to reap.Https://git.oschina.net/
The most common way of identity authentication is to use the user name (or email) and password to do the login operation. This means implementing a landing form so that users can log in with their personal information. The form looks like this:form
Many times in the Web can be applied to identity authentication, this article introduced the ANGULARJS application of identity authentication skills, nonsense not to say a look down together.
Identity Certification
The most common way of identity
Today, let's take a look at the routing module in angular. In our actual project, the switching of each page is often related to auth. For example, the background of my site, is required to login to the user to go in, then we use ANGULARJS to do the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.